home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / contrib / src-client / winterp2.el < prev   
Encoding:
Text File  |  1991-10-06  |  6.4 KB  |  144 lines

  1. ;; Reply-To: wolfe@sybase.com
  2. ;; To: mayer@hplnpm.hpl.hp.com
  3. ;; Subject: Slighlty improved winterp.el
  4. ;; Date: Wed, 24 Apr 91 17:42:11 -0700
  5. ;; From: wolfe@sybase.com
  6. ;; 
  7. ;; Following is a version of winterp.el that I hacked up to make the
  8. ;; winterp-send-* functions a little more general. I added:
  9. ;; winterp-send-area
  10. ;; winterp-send-region
  11. ;; I modified:
  12. ;; winterp-send-buffer
  13. ;; winterp-send-defun
  14.  
  15. ; -*-Emacs-Lisp-*-
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. ;
  18. ; File:         winterp.el
  19. ; RCS:          $Header: /seq5/u/wolfe/Src/winterp-1.11/src-client/RCS/winterp.el,v 1.1 91/04/12 22:51:55 wolfe Exp Locker: wolfe $
  20. ; Description:  GNUEMACS lisp-mode interface to WINTERP.
  21. ; Author:       Niels Mayer, HPLabs
  22. ; Created:      Tue Nov 14 23:14:54 1989
  23. ; Modified:     Fri Dec 15 17:46:07 1989 (Niels Mayer) mayer@hplnpm
  24. ; Language:     Emacs-Lisp
  25. ; Package:      N/A
  26. ; Status:       X11r4 contrib tape release
  27. ;
  28. ; WINTERP Copyright 1989-1991 Hewlett-Packard Company (by Niels Mayer).
  29. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  30. ;
  31. ; Permission to use, copy, modify, distribute, and sell this software and its
  32. ; documentation for any purpose is hereby granted without fee, provided that
  33. ; the above copyright notice appear in all copies and that both that
  34. ; copyright notice and this permission notice appear in supporting
  35. ; documentation, and that the name of Hewlett-Packard and David Betz not be
  36. ; used in advertising or publicity pertaining to distribution of the software
  37. ; without specific, written prior permission.  Hewlett-Packard and David Betz
  38. ; make no representations about the suitability of this software for any
  39. ; purpose. It is provided "as is" without express or implied warranty.
  40. ;
  41. ; HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  42. ; SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  43. ; IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  44. ; INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  45. ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  46. ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  47. ; PERFORMANCE OF THIS SOFTWARE.
  48. ;
  49. ; See ./winterp/COPYRIGHT for information on contacting the authors.
  50. ; Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  51. ; Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  52. ;
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54.  
  55.  
  56. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  57. ;; Make sure shell.el is loaded, since this file uses stuff defined there.
  58. ;; None of this will work unless you load shell.el from emacs
  59. ;; versions >= 18.54. I also expect that lisp-mode has been preloaded into
  60. ;; gnuemacs (it is automatically loaded by default in "normal" gnuemacsen)
  61. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  62. (require 'shell)
  63.  
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  65. (defvar winterp-client-shell "sh" 
  66.   "A shell in which to run the winterp-server client 'wl' any shell will do
  67. e.g. sh, csh, ksh....")
  68.  
  69. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  70. (defvar winterp-client-program "wl"
  71.   "The name of the client program that sends lisp expressions to the
  72. winterp lisp server. You may want to change this if you use a different
  73. client program, or if you  don't have 'wl' on your search path, you
  74. may want to specify a full path to 'wl'.") 
  75.  
  76. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  77. (defvar winterp-client-program-args ""
  78.   "This sets the arguments sent to 'wl'. You may want to set this to
  79. \"-h <hostname> -p <portnum>\" if you are running  winterp on a different
  80. host than gnuemacs, or if you want to run winterp on a TCP port other than
  81. the default, which is 23751.")
  82.  
  83. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84. (defun winterp-send-exit ()
  85.   "Calling this function will send WINTERP a command to exit the current
  86. breaklevel. If not at a breaklevel, then WINTERP will exit."
  87.   (interactive)
  88.   (if (not (get-process "winterp-client-shell"))
  89.       (make-shell "winterp-client-shell" winterp-client-shell)
  90.     )
  91.   ;;sending wl with no args sends an EOF to WINTERP which signals XLISP to
  92.   ;;exit the current breaklevel, or exit if not in the breakloop.
  93.   (process-send-string "winterp-client-shell" 
  94.                (format "%s %s\n"
  95.                    winterp-client-program winterp-client-program-args))
  96.   )
  97.  
  98. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  99. (defun winterp-send-defun ()
  100.   "Send current lisp expression to the winterp server"
  101.   (interactive)
  102.   (save-excursion
  103.     (winterp-send-area (progn (beginning-of-defun) (point))
  104.                (progn (end-of-defun) (point)))))
  105.  
  106. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  107. (defun winterp-send-buffer ()
  108.   "Send current buffer to the winterp server"
  109.   (interactive)
  110.   (winterp-send-area (point-min) (point-max)))
  111.  
  112. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  113. (defun winterp-send-region ()
  114.   "Send current region to the winterp server"
  115.   (interactive)
  116.   (if (< (point) (mark))
  117.       (winterp-send-area (point) (mark))
  118.     (winterp-send-area (mark) (point))))
  119.  
  120. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  121. (defun winterp-send-area (start-region end-region)
  122.   "Send all characters between START-REGION and END-REGION to winterp server"
  123.   (if (not (get-process "winterp-client-shell"))
  124.       (make-shell "winterp-client-shell" winterp-client-shell))
  125.   (let (
  126.     (loadfile (format "/tmp/wl%d.lsp"
  127.               (process-id (get-process "winterp-client-shell")))))
  128.     (save-excursion (write-region start-region end-region
  129.                   loadfile nil 'nomessage))
  130.     (process-send-string "winterp-client-shell"
  131.              (format
  132.               "%s %s '(load \"%s\" :verbose nil :print t)'\n"
  133.               winterp-client-program winterp-client-program-args
  134.               loadfile))))
  135.  
  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137.  
  138. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  139. ;; rebind some keys in lisp-mode-map (assumed preloaded in gnuemacs).
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  141. (define-key lisp-mode-map "\C-c\C-d" 'winterp-send-exit)
  142. (define-key lisp-mode-map "\e\C-x" 'winterp-send-defun)
  143.